public class DuoTaiDemo08 {

    public static void main(String[] args) {
        // 父类引用指向子类对象
        YiYue yiYue = new GangQin();
        sound(yiYue);
    }

    public static void sound(YiYue yiYue){
        yiYue.music();
    }

}


class YiYue {
    private String name;

    public YiYue() {
    }

    public YiYue(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void music() {
        System.out.println("产生音乐");
    }
}

class DiZi extends YiYue {

    @Override
    public void music() {
        System.out.println("吹笛子");
    }
}


class ErHu extends YiYue {
    @Override
    public void music() {
        System.out.println("拉二胡");
    }
}

class GangQin extends YiYue {
    @Override
    public void music() {
        System.out.println("弹钢琴");
    }
}